home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-25 | 6.4 KB | 289 lines | [TEXT/MPS ] |
- #========================================================================================
- #
- # File: FWPreBuild
- # Release Version: $ ODF 1 $
- #
- # Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- #
- #========================================================================================
-
- # This script is used for "pre-building" ODF targets.
- #
- # By "pre-building" we refer to the process of generating SOM
- # ≈.xh files from their ≈.idl counterparts as well as generating
- # ≈.rsrc resource file from ≈.r and ≈.fr sources. This is normally
- # done only once and need not be done again unless an ≈.idl, ≈.fr,
- # ≈.r file is revised.
-
- Set TraceFailures 1
- Export TraceFailures
-
- # Save our current directory so we can restore it later.
-
- Set StartDir "``Directory -q``"
-
- # Initialize script vars
-
- Set DefRul "{FWToolsDir}FWPreBuild.rul"
- Set TempFile "{TempFolder}{0}.out"
- Set somDir "Include"
- Set resDir "Other"
- Set Progress 0
- Set Dump 0
- Set NoCleanup 0
-
- Set Usage "Usage: {0} [-som somDirectory] [-res resDirectory] [-p] [-dump] Target1 Target2..."
-
- # Parse for flags and remove them from param list as we go
-
- Loop
- If "{1}" =~ /-som/
- Set somDir "{2}"
- Shift
- Else If "{1}" =~ /-res/
- Set resDir "{2}"
- Shift
- Else If "{1}" =~ /-help/
- Echo "{Usage}"
- Echo "∂t-som∂t--> location of the SOM idl files within target directory (default ∂'{somDir}∂')."
- Echo "∂t-res∂t--> location of the resource files within target directory (default ∂'{resDir}∂')."
- Echo "∂t-p ∂t--> give progress info as script executes."
- Echo "∂t-dump∂t--> create the MakeFile but don't execute it."
- Exit 0
- Else If "{1}" =~ /-p/
- Set Progress 1
- Else If "{1}" =~ /-dump/
- Set Dump 1
- Set NoCleanup 1
- Else
- Break
- End
- Shift
- End
-
- # If no remaining parameters then we print a usage string and exit
-
- If {#} == 0
- Echo "{Usage}"
- Echo "∂t-som∂t--> location of the SOM idl files within target directory (default ∂'{somDir}∂')."
- Echo "∂t-res∂t--> location of the resource files within target directory (default ∂'{resDir}∂')."
- Echo "∂t-p ∂t--> give progress info as script executes."
- Echo "∂t-dump∂t--> create the MakeFile but don't execute it."
- Exit 0
- End
-
- # Unless we specified the -dump option the MakeFile
- # is generated in the MPW temp folder located inside
- # the MPW prefs folder. If we did specify the -dump
- # option it is generated in the target's directory.
-
- If {Dump} == 0
- Set MakeFile "{TempFolder}tmp.make"
- Else
- Set MakeFile "Prebuild.make"
- End
-
- If {Progress}
- Echo "Executing FWPreBuild for target(s): {Parameters}"
- Echo "∂tSOM directory: ∂'{somDir}∂'"
- Echo "∂tResource directory: ∂'{resDir}∂'"
- End
-
- # Since we can specify multiple targets we will iterate through
- # them and attempt to invoke SOM, ODFrc, and Rez as needed for
- # each target.
-
- For TargItem in {Parameters}
-
- # First see if they forgot the trailing colon on the target. path
- # If so we add it for them.
-
- If {TargItem} =~ /≈:/
- Set TargFldr "{TargItem}"
- Else
- Set TargFldr "{TargItem}:"
- End
-
- # Make sure the target folder exists
-
- If ¬ `Exists "{TargFldr}"`
- Echo "# Error: Can not find target folder ∂'{TargFldr}∂'!"
- Directory "{StartDir}"
- Exit 1
- Else If {Progress}
- Echo "# -------"
- Echo "Looking in target folder ∂'{TargFldr}∂'"
- End
-
- # Set directory to target folder
-
- Directory "{TargFldr}"
-
- # delete previous temp file if it exists.
-
- If `Exists {MakeFile}`
- Delete "{MakeFile}"
- End
-
- # Set the list of files to empty and clear flags.
-
- Set FList ""
- Set GotIDL 0
- Set GotFR 0
- Set GotR 0
-
- # Next make sure the SOM IDL folder exists.
-
- If ¬ `Exists ":{somDir}:"`
- Echo "# Warning: Can not find SOM IDL folder ∂'{TargFldr}{somDir}:∂'!"
- Else
-
- If {Progress}
- Echo "Looking in theSOM IDL folder ∂'{TargFldr}{somDir}:∂'"
- End
-
- # Look for .idl files in the SOM folder.
-
- Set LList "`Files :{somDir}:`"
- If {Progress}
- Echo "∂tScanning for .idl files in ∂':{somDir}:∂'"
- End
- For item in {LList}
- If "{Item}" =~ /≈.idl/
- Set FList "{FList} :{somDir}:'{item}'"
- Set GotIDL 1
- End
- End
- End
-
- # Now make sure the resource folder exists.
-
- If ¬ `Exists ":{resDir}:"`
- Echo "# Warning: Can not find resource folder ∂'{TargFldr}{resDir}:∂'!"
- Else
- If {Progress}
- Echo "Looking in resource folder ∂'{TargFldr}{resDir}:∂'"
- End
-
- # Look for .fr files in the resource folder.
-
- Set LList "`Files :{resDir}:`"
- If {Progress}
- Echo "∂tScanning for .fr files in ∂':{resDir}:∂'"
- End
- For item in {LList}
- If "{Item}" =~ /≈.fr/
- Set FList "{FList} :{resDir}:'{item}'"
- Set GotFR 1
- End
- End
-
- # Look for .r files in the resource folder.
-
- Set LList "`Files :{resDir}:`"
- If {Progress}
- Echo "∂tScanning for .r files in ∂':{resDir}:∂'"
- End
- For item in {LList}
- If "{Item}" =~ /≈.r/
- Set FList "{FList} :{resDir}:'{item}'"
- Set GotR 1
- End
- End
- End
-
- # If we found any files while scanning, generate the
- # makefile and execute it.
-
- If "{FList}" != ""
-
- # Copy the default rules to the makefile.
-
- If `Exists "{DefRul}"`
- Catenate "{DefRul}" > "{MakeFile}"
- Else
- Echo "# Error: Can't find default make rules in file: ∂'{DefRul}∂'"
- Directory "{StartDir}"
- Exit 1
- End
-
- # Emit the root dependency.
-
- Echo "∂nroot ƒ ∂∂" >> "{MakeFile}"
-
- For Name in {FList}
- If {Progress}
- Echo "∂tEmiting root depedency for {Name}"
- End
-
- Echo "∂t{Name} ∂∂" >> "{MakeFile}"
- End
-
- # Emit the real make dependencies.
-
- For Name in {FList}
- If {Progress}
- Echo "∂tEmiting depedency for {Name}"
- End
-
- Echo "∂n{Name} ƒ {Name}" >> "{MakeFile}"
- End
-
- # We must edit the results slightly.
-
- Open -t "{MakeFile}"
- Find •
- If {GotIDL}
- Replace /.idl ∂∂/ '.xh ∂' -c ∞
- End
- If {GotFR}
- Replace /.fr ∂∂/ '.rsrc ∂' -c ∞
- End
- If {GotR}
- Replace /.r ∂∂/ '.rsrc ∂' -c ∞
- End
- Replace \ ∂∂\ ' ' -c 1
- If {GotIDL}
- Replace /.idl ƒ/ '.xh ƒ' -c ∞
- End
- If {GotFR}
- Replace /.fr ƒ/ '.rsrc ƒ' -c ∞
- End
- If {GotR}
- Replace /.r ƒ/ '.rsrc ƒ' -c ∞
- End
- Close -y "{MakeFile}"
-
- # Execute the make unless we specified -dump.
-
- If {Dump} == 0
-
- If {Progress}
- Echo "Running Make for {MakeFile}"
- End
-
- Echo "Set Exit 1" > "{TempFile}"
- Make -f "{MakeFile}" >> "{TempFile}"
- Execute "{TempFile}"
- Delete "{TempFile}"
- End
-
- Else
- Echo "# Warning: No .idl, .fr, or .r files found!"
- End
-
- # Set our directory back to where we were when we executed this script.
-
- Directory "{StartDir}"
- End
-
- # Unless we specified the -dump option we delete our
- # temporary MakeFile.
-
- If !{NoCleanup}
- If `Exists "{MakeFile}"`
- Delete "{MakeFile}"
- End
- End
-
-